package com.innerchic.mapper.log;

import android.util.Log;

/**
 * ================================================
 * 作    者：贾恒飞 >>> 17515250730@163.com
 * 项    目：young
 * 日    期：2021/11/2 9:38
 * 包    名：com.innerchic.mapper.log
 * 描    述：日志
 * Create by zFox from AndroidStudio4.2
 * ================================================
 */
public class Logger {

    private static final String TAG = "YOUNG-LOG";

    public static final String reTag = "@-";

    /**
     * 打印日志
     *
     * @param log 日志
     */
    public static void d(String log) {
        if (log.length() > 1024) {
            String substring = log.substring(0, 1024);
            Log.d(TAG, substring);
            log = log.replace(substring, "");
            d(log);
        } else {
            Log.d(TAG, log);
        }
    }

    public static void e(Exception e, String msg) {
        Log.e(TAG, msg, e);
    }

    public static void d(String msg, Object... all) {
        if (all.length == 0) d(msg);
        for (Object o : all) {
            msg = msg.replaceFirst(reTag, String.valueOf(o));
        }
        d(msg);
    }

    public static void e(Exception e, String msg, Object... all) {
        if (all.length == 0) e(e, msg);
        for (Object o : all) {
            msg = msg.replaceFirst(reTag, String.valueOf(o));
        }
        e(e, msg);
    }

}
